﻿@model AccountDropdownModel
@using SmartStore.Web.Models.Common;
@using SmartStore.Web.Models.Customer;
@using SmartStore.Core;
@using SmartStore.Core.Infrastructure;
@using SmartStore.Core.Infrastructure.DependencyManagement;
@{
    //register URL with return URL (if specified)
    var registerUrl = Url.RouteUrl("Register");
    if (!String.IsNullOrEmpty(this.Context.Request.QueryString["returnUrl"]))
    {
        var webHelper = EngineContext.Current.Resolve<IWebHelper>();
        registerUrl = webHelper.ModifyQueryString(registerUrl, "returnurl=" + HttpUtility.UrlEncode(this.Context.Request.QueryString["returnUrl"]), null);
    }    
}

@if (Model.IsAuthenticated)
{
    <ul class="dropdown-menu shopbar-flyout-container">
        <li>
            <a href="@Url.RouteUrl("CustomerInfo")">
                <i class="icon-user"></i> 
                @T("Account.MyAccount")
            </a>
        </li>
        @if (Model.DisplayAdminLink)
        {
            <li>
                <a href="@Url.Content("~/admin")" target="_admin">
                    <i class="icon-cog"></i> 
                    @T("Account.Administration")
                </a>
            </li>
        }
        
        @if (Model.AllowPrivateMessages)
        {
        <li>
            <a href="@Url.RouteUrl("PrivateMessages", new { tab = "" })">
                <i class="icon-envelope"></i>
                @T("PrivateMessages.Inbox")  
                @if (Model.UnreadPrivateMessages != "")
                {
                    <span class="badge badge-success">@Model.UnreadPrivateMessages</span>
                }
                </a>
        </li>
        if (!string.IsNullOrEmpty(Model.AlertMessage))
            {
                <script type="text/javascript">
                    $(document).ready(function () {
                        displayNotification('@(Model.AlertMessage)', 'info');
                    });
                </script>
            }
        }
        
        @*<li class="divider"></li>*@

        @if (Model.WishlistEnabled)
        {
            <li>
                <a href="@Url.RouteUrl("Wishlist")">
                    <i class="icon-gift"></i>
                    @T("Wishlist") <span class="wishlist-qty badge @(Model.WishlistItems > 0 ? "badge-success" : "")">@Model.WishlistItems</span></a> 
            </li>
        }
        @if (Model.ShoppingCartEnabled)
        {
            <li id="topcartlink">
                <a href="@Url.RouteUrl("ShoppingCart")">
                    <i class="icon-shopping-cart"></i>
                    @T("ShoppingCart") <span class="cart-qty badge @(Model.ShoppingCartItems > 0 ? "badge-success" : "")" data-bind-to="TotalProducts">@Model.ShoppingCartItems</span></a>
            </li>
        }
        <li class="divider"></li>
        <li>
            <a href="@Url.RouteUrl("Logout")">
                <i class="icon-signout"></i>
                @T("Account.Logout")</a>
        </li>
    </ul>
} 
else {
    
    @*<div class="shopbar-flyout" id="shopbar-flyout-account">
        <div class="shopbar-flyout-inner">
           
            @using (Html.BeginForm("Login", "Customer", FormMethod.Post))
            {
                <div class="message-error">
                    @Html.ValidationSummary(true, T("Account.Login.Unsuccessful").Text)
                </div>
                    
                if (Model.UsernamesEnabled)
                {
                    <div class="control-group">
                        @Html.LabelFor(model => model.Username, new { @class = "control-label", @for = "Username" })
                        <div class="controls">
                            @Html.TextBoxFor(m => m.Username, new { @class = "username" })
                            @Html.ValidationMessageFor(m => m.Username)
                        </div>
                    </div>
                }
                else
                {
                    <div class="control-group">
                        @Html.LabelFor(model => model.Email, new { @class = "control-label", @for = "Email" })
                        <div class="controls">
                            @Html.TextBoxFor(m => m.Email, new { @class = "email" })
                            @Html.ValidationMessageFor(m => m.Email)
                        </div>
                    </div>
                }
                                        
                <div class="control-group">
                    @Html.LabelFor(model => model.Password, new { @class = "control-label", @for = "Password" })
                    <div class="controls">
                        @Html.PasswordFor(m => m.Password, new { @class = "password" })
                        @Html.ValidationMessageFor(m => m.Password)
                    </div>
                </div>
                    
                <div class="control-group">
                    <label class="control-label">
                        @Html.CheckBoxFor(m => m.RememberMe, new { @class="inline" }) @T("Account.Login.Fields.RememberMe").Text
                    </label>
                </div>
                    
                <div class="buttons">
                    <button class="btn btn-primary pull-right" type="submit">@T("Account.Login.LoginButton")</button>
                </div>
    
                <div class="clear">
                </div>
    
                <div class="forgot-password pull-right">
                    @Html.RouteLink(T("Account.Login.ForgotPassword").Text, "PasswordRecovery")
                </div>
    
                <div class="clear">
                </div>
            }
        
            <div class="register">
                <button class="btn" onclick="location.href='@registerUrl'">@T("Account.Register")</button>
            </div>
    
        </div>    
    </div>*@
}